package com.jchy.renderit.core;
 
public abstract class Displayable extends Matrix
{
    protected double ambient, diffuse, phongCoef, phongExp;
    private java.awt.Color primaryColor;

    public Displayable()
    {
        ambient=0.2;
        diffuse=0.8;
        phongCoef=0.0;
        phongExp=1;
        primaryColor=new java.awt.Color(255,255,255);
    }    

    public void setPrimaryColorInt(int red, int green, int blue)
    {
        primaryColor=new java.awt.Color(red, green, blue);
    }

    public void SetShading(double inAmbient, double inDiffuse, double inPhongCoef, double inPhongExp)
    {
        // Scale parameters so ambient+diffuse+phong = 1.0
        double total;
        total=inAmbient+inDiffuse+inPhongCoef;
        if(total>1.0)
        {
            ambient=inAmbient/total;
            diffuse=inDiffuse/total;
            phongCoef=inPhongCoef/total;
        }
        else
        {
            ambient=inAmbient;
            diffuse=inDiffuse;
            phongCoef=inPhongCoef;
        }
        phongExp=inPhongExp;
    }
    public double GetAmbient()
    {
        return ambient;
    }
    public double GetDiffuse()
    {
        return diffuse;
    }
    public double GetPhongCoef()
    {
        return phongCoef;
    }
    
    public double GetPhongExp()
    {
        return phongExp;
    }
    
    public abstract Hit intersect(Point prp, Point vrp);
//    {
//        Hit aHit = new Hit();
//        return aHit;
//    }

    public int getPrimaryColorRed()
    {
        return primaryColor.getRed();
    }

    public int getPrimaryColorGreen()
    {
        return primaryColor.getGreen();
    }

    public int getPrimaryColorBlue()
    {
        return primaryColor.getBlue();
    }

    public String showMatrix()
    {
        String result=super.toString();
        return result;
    }

    public String toString()
    {
        String result="Location: " + super.getTransTo().toString();
        result=result+"\nPrimary Color: (" + primaryColor.getRed() + ", " +
                                             primaryColor.getGreen() + ", " +
                                             primaryColor.getBlue() + ") " +
                      "\nAmbient: " + ambient +
                      " Diffuse: " + diffuse +
                      "\nPhong Coefficient: " + phongCoef +
                      " Phong Exponent: " + phongExp;
        return result;
    }
}
